import time
def base_response(code=200, message='', data=None):
    """
    :param code: 状态码
    :param message: 状态信息
    :param data: 数据
    :return:
    """
    return {
        'code': code,
        'message': message,
        'data': data,
        'time': int(time.time())
    }
def success(data=None, message=None):
    """
    :param data: 数据
    :param message: 信息
    :return:
    """
    if not message:
        if isinstance(data, str):
            message = data
        else:
            message = 'success'
    return base_response(code=200, message=message, data=data)
def error(message=None,code=500, data=None):
    """
    :param message: 信息
    :param code: 状态码
    :param data: 数据
    :return:
    """
    if not message:
        if isinstance(data, str):
            message = data
        else:
            message = 'error'
    return base_response(code=code, message=message, data=data)